var id = $.url('id');
var appVue = new Vue({
	el:'#app',
	data:{
		base:{
			'company.id':session.getSchID(),
			'id':id,
			'user.name':'',
			'user.idno':'',
			'user.sex':'',
			'user.birthday':'',
			'user.mobile':'',
			'user.email':'',
			'user.qq':'',
			'user.weixin':''
		}
	},
	methods:{
		submit:function(){
			if(id){
				$.put({
					url:'employees/'+id,
					data:this.base,
					success:function(res){
						if(res.code == 200){
							toastr['info']('操作成功！', '提示信息');
							setTimeout(function(){location.href='list.html'},config.alertTime);
						}else{
							toastr['error'](res.msg, '错误信息');
						}
					}
				});
			} else {
				$.post({
					url:'employees',
					data:this.base,
					success:function(res){
						if(res.code == 200){
							toastr['info']('操作成功！', '提示信息');
							setTimeout(function(){location.href='list.html'},config.alertTime);
						}else{
							toastr['error'](res.msg, '错误信息');
						}
					}
				});
			}
		}
	}
});
if(id){
	$.getData({
		url:'employees/'+id,
		success:function(res){
			var o = res.data;
			for(var i in o){
				var oi = o[i];
				if(oi){
					if(typeof oi == 'object'){
						for(var j in oi){
							if(oi[j] && typeof appVue.base[i+'.'+j] != 'undefined') appVue.base[i+'.'+j] = oi[j];
						}
					}else{
						if(typeof appVue.base[i] != 'undefined')appVue.base[i] = o[i];
					}
				}
			}
		}
	})
}